﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.GateUI {
    import flash.events.*;
    import flash.display.*;
    import Events.*;
    import org.aswing.*;
    import Classes.*;
    import flash.filters.*;
    import flash.text.*;
    import Display.aswingui.*;
    import L10n.*;

    public class CrewKeyCell extends KeyCell {

        private var m_footerText:String;
        private var m_backgroundClass:Class;

        public function CrewKeyCell(_arg1:String, _arg2:String, _arg3:Number, _arg4:Number, _arg5:String, _arg6:Class, _arg7:Class=null){
            super(_arg1, _arg2, _arg3, _arg4, _arg7);
            this.m_footerText = _arg5;
            this.m_backgroundClass = _arg6;
            HPADDING = 0;
        }
        override protected function createHeaderComponent():Component{
            var _local1:Container = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:AssetPane = ASwingHelper.makeMultilineCapsText(m_name, 100, EmbeddedArt.TITLE_FONT, TextFormatAlign.CENTER, 13, 14123308, null, false, 35);
            var _local3:TextField = (_local2.getAsset() as TextField);
            while (_local3.numLines < 2) {
                m_name = ("\n" + m_name);
                _local2 = ASwingHelper.makeMultilineCapsText(m_name, 100, EmbeddedArt.TITLE_FONT, TextFormatAlign.CENTER, 13, 14123308, null, false, 35);
                _local3 = (_local2.getAsset() as TextField);
            };
            _local1.append(_local2);
            return (_local1);
        }
        override protected function createTopButtonComponent():Component{
            return (null);
        }
        override protected function createBottomButtonComponent():Component{
            var _local1:Container = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:AssetIcon = new AssetIcon((new EmbeddedArt.icon_cash() as DisplayObject));
            var _local3:CustomButton = new CustomButton(m_cost.toString(), _local2, "BuyGateKeyButtonUI");
            _local3.addEventListener(MouseEvent.CLICK, this.onBuyClick);
            var _local4:Insets = _local3.getMargin();
            _local3.setMargin(new Insets(_local4.top, (_local4.left + 2), (_local4.bottom + 3), (_local4.right + 2)));
            _local1.append(_local3);
            return (_local1);
        }
        override protected function createFooterComponent():Component{
            var _local1:Container = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            m_itemCount = new JLabel(this.m_footerText);
            m_itemCount.setForeground(new ASColor(3776202, 1));
            m_itemCount.setFont(ASwingHelper.getBoldFont(14));
            m_itemCount.setTextFilters([new GlowFilter(0xFFFFFF, 1, 2, 2, 10)]);
            var _local2:JTextField = ASwingHelper.makeTextField(this.m_footerText, EmbeddedArt.TITLE_FONT, 14, 3776202);
            _local2.getTextField().filters = [new GlowFilter(0xFFFFFF, 1, 2, 2, 10)];
            _local2.setPreferredWidth(60);
            _local2.setPreferredHeight(20);
            LocaleHelper.localSetting.TextField_adjust(_local2.getTextField(), {
                embedFonts:false,
                font:EmbeddedArt.SYSTEM_FONT,
                autoSize:"center"
            });
            _local1.append(_local2);
            return (_local1);
        }
        override protected function createImageComponent():Component{
            var _local1:Container = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.BOTTOM);
            var _local3:Sprite = new Sprite();
            var _local4:DisplayObject = new this.m_backgroundClass();
            _local3.addChild(_local4);
            _local3.addChild(m_itemIcon);
            m_itemIcon.x = ((_local4.width - m_itemIcon.width) / 2);
            m_itemIcon.y = ((_local4.height - m_itemIcon.height) / 2);
            var _local5:AssetPane = new AssetPane(_local3);
            _local2.appendAll(_local5);
            _local3.buttonMode = true;
            _local3.addEventListener(MouseEvent.CLICK, this.inviteFriends, false, 0, true);
            _local1.append(ASwingHelper.verticalStrut(75));
            _local1.append(_local2);
            return (_local1);
        }
        private function inviteFriends(_arg1:MouseEvent):void{
            dispatchEvent(new Event("friendClicked", true));
        }
        override protected function onBuyClick(_arg1:MouseEvent):void{
            var _local3:Player;
            if (!LocaleHelper.localSetting.sns.cash_enable){
                return;
            };
            var _local2:Boolean = m_buyCallback(m_cost);
            if (_local2){
                m_count++;
                _local3 = Global.player.findFriendById("-1");
                m_url = _local3.snUser.picture;
                this.m_footerText = _local3.firstName;
                setCellValue(m_value);
                initializeCell();
            };
        }
        override protected function createActionCompleteComponent():Component{
            var _local1:Container = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            if (m_footerComponent){
                _local1.append(m_footerComponent);
            };
            if (m_askHolder){
                _local1.append(m_askHolder);
            };
            return (_local1);
        }
        override protected function onIconFail(_arg1:Event):void{
            m_displayObjectClass = EmbeddedArt.hud_no_profile_pic;
            m_itemIcon = new m_displayObjectClass();
            onIconLoad(_arg1);
        }
        override protected function onWishlistChanged(_arg1:DataItemEvent):void{
        }

    }
}//package Display.GateUI 
